package com.yanwq.sayhi.repository;

import com.yanwq.sayhi.bean.Club;
import com.yanwq.sayhi.bean.ClubVip;
import com.yanwq.sayhi.bean.User;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

/**
 * 作者：闫伟强。
 * 日期：2016/6/14。
 */
@Repository
public interface ClubVipRepo extends CrudRepository<ClubVip, Long> {

    @Transactional
    void removeByUserAndClub(User user, Club club);

    Page<ClubVip> findByClubOrderByIdDesc(Club club, Pageable pageable);

    Page<ClubVip> findByUserOrderByIdDesc(User user, Pageable pageable);

    Page<ClubVip> findByUserAndPositionOrderByIdDesc(User user, int position, Pageable pageable);

    int countByUserAndClub(User user, Club club);
}
